package edu.bbu.commonproject.backend.db.services;


import java.util.ArrayList;

import edu.bbu.commonproject.backend.db.exceptions.DataBaseErrorException;
import edu.bbu.commonproject.backend.db.exceptions.FileDownloadException;
import edu.bbu.commonproject.backend.db.exceptions.FileNotExistException;
import edu.bbu.commonproject.backend.db.exceptions.FileUploadException;
import edu.bbu.commonproject.backend.db.model.DBDirectory;
import edu.bbu.commonproject.backend.db.model.DBFile;

/**
 * Interfaces that all FileDAOServices must support.  
 */

public interface FileDAOServices
{
	/**
	 * This method upload a file.
	 * @param file the file model. 
	 * @throws FileUploadException if can not upload files. 
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract void uploadFile(DBFile file) throws FileUploadException, DataBaseErrorException;
	
	/**
	 * This method download a file.
	 * @param file the file model.
	 * @throws FileNotExistException if file not exists.
	 * @throws FileDownloadException if can not download files.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract void downloadFile(DBFile file) throws FileNotExistException, FileDownloadException, DataBaseErrorException;
	
	/**
	 * This method return the last version a file.
	 * @param file the file model.
	 * @return given file last version number.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract int getLastVersionNumber(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method get number of file version.
	 * @param file the file model.
	 * @return given file number of version.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract int getNumberOFVersions(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method get a list of file version.
	 * @param file the file model.
	 * @return a list with file version.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract ArrayList<Integer> getVersionNumbers(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method delete the given file.
	 * @param file the file model.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract void deleteFile(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method delete all version a file given.
	 * @param file the file model.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract void deleteAllFileVersions(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method return the given file size.
	 * @param file the file model.
	 * @return the file size.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract long getFileSize(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method return the given file upload date.
	 * @param file the file model.
	 * @return the file size.
	 * @throws FileNotExistException if file not exists.
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract long getFileUploadDate(DBFile file) throws FileNotExistException, DataBaseErrorException;
	
	/**
	 * This method get all files from given directory.
	 * @param directory the directory model.
	 * @return a list from files. 
	 * @throws DataBaseErrorException if error occurred in database.
	 */
	public abstract ArrayList<String> getFilesFromDirectory(DBDirectory directory) throws DataBaseErrorException;
	
}
